﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Windows.Media.Media3D;

namespace GameBoard
{
    public class KeyToDirection
    {
        public enum MovementDirection
        {
            NW, N, NE, W, E, SW, S, SE
        }
        internal KeyToDirection(Key theInput, MovementDirection desired)
        {
            TheInput = theInput;
            DesiredDirection = desired;
        }

        internal MovementDirection DesiredDirection { get; set; }

        internal Key TheInput { get; set; }

        public static Vector3D VectorFromDirection(MovementDirection target)
        {
            double x = 0, y = 0, z = 0;
            switch (target)
            {
                case MovementDirection.N:
                    x = 0;
                    y = 1;
                    break;
                case MovementDirection.NE:
                    x = .5;
                    y = .5;
                    break;
                case MovementDirection.NW:
                    x = -.5;
                    y = .5;
                    break;
                case MovementDirection.W:
                    x = -1;
                    y = 0;
                    break;
                case MovementDirection.E:
                    x = 1;
                    y = 0;
                    break;
                case MovementDirection.SE:
                    x = .5;
                    y = -.5;
                    break;
                case MovementDirection.S:
                    x = 0;
                    y = -1;
                    break;
                case MovementDirection.SW:
                    x = -.5;
                    y = -.5;
                    break;
            }
            var ret = new Vector3D(x,y,z);
            ret.Normalize();
            return ret;
        }
    }
}
